package com.nuc.thread.create;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @Description
 * @Author 诗酒趁年华
 * @Version V1.0.0
 * @Date 2021/5/4
 */
@Slf4j
public class CreateThread3 {
    @SneakyThrows
    public static void main(String[] args) {
        FutureTask<Integer> futureTask = new FutureTask<>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                log.debug("running");
                Thread.sleep(2000);
                return 100;
            }
        });
        Thread thread = new Thread(futureTask,"t3");
        thread.start();

        Integer integer = futureTask.get();
        log.debug("main running"+integer);
    }
}
